package configmap

import (
	"gitee/yinlai/kms-backend/controllers"
	"gitee/yinlai/kms-backend/utils/logs"
	"github.com/dotbalo/kubeutils/kubeutils"
	"github.com/gin-gonic/gin"
)

func Delete(r *gin.Context) {
	logs.Debug(nil, "删除Configmap")

	var info controllers.Info

	kubeconfig := controllers.NewInfo(r, &info, "删除成功")
	// 使用kubeUtils 接口实现资源创建
	var kubeUtilser kubeutils.KubeUtilser
	instance := kubeutils.NewConfigMap(kubeconfig, nil)
	kubeUtilser = instance
	info.Delete(r, kubeUtilser)
}

func DeleteList(r *gin.Context) {
	logs.Debug(nil, "删除Configmap列表")

	var info controllers.Info

	kubeconfig := controllers.NewInfo(r, &info, "删除成功")
	// 使用kubeUtils 接口实现资源创建
	var kubeUtilser kubeutils.KubeUtilser
	instance := kubeutils.NewConfigMap(kubeconfig, nil)
	kubeUtilser = instance
	info.DeleteList(r, kubeUtilser)
}

//func Delete1(r *gin.Context) {
//	logs.Debug(nil, "删除Pod")
//
//	clientset, basicInfo, err := controllers.BasicInit(r, nil)
//	returnData := config.ReturnData{}
//	if err != nil {
//		returnData.Message = err.Error()
//		returnData.Status = 400
//		r.JSON(http.StatusOK, returnData)
//		return
//	}
//
//	logs.Warning(map[string]interface{}{"deleteList": basicInfo.DeleteList}, "删除多个pod")
//	// 实现删除多个pod
//	for _, v := range basicInfo.DeleteList {
//		_ = clientset.CoreV1().Pods(basicInfo.Namespace).Delete(context.TODO(), v, metav1.DeleteOptions{})
//	}
//	////err = clientset.CoreV1().Pods(basicInfo.Namespace).Delete(context.TODO(), basicInfo.Name, metav1.DeleteOptions{})
//	//if err != nil {
//	//	logs.Error(map[string]interface{}{"id": basicInfo.ClusterId, "msg": err.Error()}, "删除Pod失败")
//	//	msg := "删除Pod失败：" + err.Error()
//	//	returnData.Status = 400
//	//	returnData.Message = msg
//	//} else {
//	//	returnData.Message = "删除成功"
//	//	returnData.Status = 200
//	//}
//	returnData.Message = "删除成功"
//	returnData.Status = 200
//	r.JSON(http.StatusOK, returnData)
//}
